package com.sjk.flink.kafka;

import com.sjk.flink.pojo.OutPutPojo;
import org.apache.flink.streaming.connectors.kafka.KafkaSerializationSchema;
import org.apache.kafka.clients.producer.ProducerRecord;
import javax.annotation.Nullable;

public class QsttyKafkaSerializationSchema implements KafkaSerializationSchema<OutPutPojo> {

    private static final long serialVersionUID = 8497940668660042203L;

    private String name;
    public QsttyKafkaSerializationSchema(String name) {
        this.name = name;
    }

    @Override
    public ProducerRecord<byte[], byte[]> serialize(OutPutPojo outPutPojo, @Nullable Long aLong) {
        return new ProducerRecord<byte[], byte[]>(name, outPutPojo.getJson().getBytes());
    }
}
